package com.molichuxing.gateway.bff.payment.convertor;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

import com.molichuxing.gateway.bff.payment.entity.response.AlipayLogVo;
import com.molichuxing.gateway.bff.payment.entity.response.OfflineBookyueVo;
import com.molichuxing.gateway.bff.payment.entity.response.WechatpayLogVo;
import com.molichuxing.services.infrastructure.dto.response.AlipayLogDto;
import com.molichuxing.services.infrastructure.dto.response.EscrowLogDto;
import com.molichuxing.services.infrastructure.dto.response.OfflineBookyueDto;
import com.molichuxing.services.infrastructure.dto.response.WechatpayLogDto;

public class Convert {


    public static List<WechatpayLogVo> toWechatpayLogVo(List<EscrowLogDto> dtoList) {
        List<WechatpayLogVo> voList = null;
        if (dtoList == null || dtoList.isEmpty()) {
            return voList;
        }
        voList = new ArrayList<>();
        for (EscrowLogDto dto : dtoList) {
            voList.add(toWechatpayLogVo(dto));
        }

        return voList;
    }

    private static WechatpayLogVo toWechatpayLogVo(EscrowLogDto dto) {
        WechatpayLogVo vo = null;
        if (dto == null) {
            return vo;
        }
        vo = new WechatpayLogVo();
        WechatpayLogDto wechatpayLogDto = (WechatpayLogDto) dto;
        BeanUtils.copyProperties(wechatpayLogDto, vo);

        vo.setRequestTime(wechatpayLogDto.getGmtCreate());
        vo.setAppid(wechatpayLogDto.getAppid());
        vo.setMchId(wechatpayLogDto.getMch_id());
        vo.setBody(wechatpayLogDto.getBody());
        vo.setOutTradeNo(wechatpayLogDto.getOut_trade_no());
        vo.setFeeType(wechatpayLogDto.getFee_type());
        vo.setTotalFee(wechatpayLogDto.getTotal_fee());
        vo.setSpbillCreateIp(wechatpayLogDto.getSpbill_create_ip());
        vo.setTradeType(wechatpayLogDto.getTrade_type());
        vo.setProductId(wechatpayLogDto.getProduct_id());

        return vo;
    }


    public static List<AlipayLogVo> toAlipayLogVo(List<EscrowLogDto> dtoList) {
        List<AlipayLogVo> voList = null;
        if (dtoList == null || dtoList.isEmpty()) {
            return voList;
        }
        voList = new ArrayList<>();
        for (EscrowLogDto dto : dtoList) {
            voList.add(toAlipayLogVo(dto));
        }

        return voList;
    }

    private static AlipayLogVo toAlipayLogVo(EscrowLogDto dto) {
        AlipayLogVo vo = null;
        if (dto == null) {
            return vo;
        }
        vo = new AlipayLogVo();
        AlipayLogDto alipayLogDto = (AlipayLogDto) dto;
        BeanUtils.copyProperties(alipayLogDto, vo);
        vo.setRequestTime(alipayLogDto.getGmtCreate());
        return vo;
    }
    
    public static OfflineBookyueVo toOfflineBookyueVo(OfflineBookyueDto dto) {
    	OfflineBookyueVo vo = null;
        if (dto == null) {
            return vo;
        }
        vo = new OfflineBookyueVo();
        BeanUtils.copyProperties(dto, vo);
        return vo;
    }
}
